﻿/// <reference path="../Scripts/qunit.js" />
/// <reference path="KataTodoList.js" />

module("KataTodoList empty", {
  setup: function () {
    this.todoList = new TodoList();
  }
});

test('todoList.todos.length', function () {
  equal(this.todoList.todos.length, 0, 'at the beginning the property "todos" is empty');
});

var comment = 'a generic comment';

module("KataTodoList not empty", {
  setup: function () {
    this.todoList = new TodoList();
    this.todoList.add(comment);
  }
});

test('todoList.todos.length', function () {
  equal(this.todoList.todos.length, 1, 'ive got one item in my todo list');
});

test('todoList.todos[0].comment', function () {
  equal(this.todoList.todos[0].comment, comment, 'the item im looking for has "a generic comment" as comment');
});

test('todoList.todos[0].id', function () {
  equal(this.todoList.todos[0].id, 1, 'the 1st has 1 as id');
});

test('todoList.todos[1].id', function () {
  this.todoList.add('another generic comment');
  equal(this.todoList.todos[1].id, 2, 'the 2nd has 2 as id');
});

test('this.todoList.toggleFlag', function () {
  this.todoList.toggleFlag(1);
  equal(this.todoList.todos[0].done, true, 'the 1st is done');
  this.todoList.toggleFlag(1);
  equal(this.todoList.todos[0].done, false, 'the 1st is undone');
});

test('this.todoList.remove', function () {
  this.todoList.remove(1);
  equal(this.todoList.todos.length, 0, 'add one item and remove one item makes the list empty');
});

test('this.todoList.remove', function () {
  this.todoList.add(comment);
  this.todoList.add(comment);
  this.todoList.add(comment);
  this.todoList.remove(3);
  equal(this.todoList.todos.length, 3, 'add 4 items and remove one item makes the total numbers of elements equal to 3');
});
